//    datetime.h
//
//     date and time routines for GPS Processing
//     This is a modfied version of the original routines created by
//     Charles Schwarz and Gordon Adams.  The functions were modified to
//     use the Remondi Date/Time algorithms (see Hilla & Jackson (2000),
//     The GPS Toolbox: The Remondi Date/Time Algorithms, GPS Solutions,
//     3(4), 71-74 ).
//
//  DateTime provides the following formats for representing a GPS-time:
//         1. GPS time (GPS week and second of week)
//         2. Modified Julian Date (MJD and fraction-of-a-day)
//         3. Year, day-of-year, hour, minute, seconds
//         4. Year, Month, day, hour, minute, seconds
//
// An object of the class DateTime may be initialized (constructed) from
//   any of the representations and viewed in any other representation.
//
// Modified by caojun_whu@126.com 2007.12.1

#if !defined( DATETIME_ )
#define  DATETIME_

#if !defined(IOSTREAM_)
#include <iostream>
#define IOSTREAM_
#endif
//#include "../GPSOBJ.h"
#include "gpsstructs.h"
namespace NGSS {

   using std::ostream;
   const double   SECPERDAY = 86400.0;

   class AFX_CLASS_EXPORT CaDateTime
   {
	  friend ostream &operator<<( ostream &output, CaDateTime &dt );

      public:
         // constructors
         CaDateTime();
         CaDateTime( GPSTIME gpstime );
         CaDateTime( MJD  mjd );
         CaDateTime( YDOYHMS yearDoyHMS );
         CaDateTime( YMDHMS yearMonthDayHMS );
         CaDateTime( long year, long month, long day,
	           long hour, long min, double sec );

         // destructor
         ~CaDateTime();

         // initializers
         void  SetGPSTime( GPSTIME gpstime );
         void  SetMJD( MJD  mjd );
         void  SetYDOYHMS( YDOYHMS yearDoyHMS );
         void  SetYMDHMS( YMDHMS yearMonthDayHMS );
         void  SetYMDHMS( long year, long month, long day,
	                  long hour, long min, double sec );

         // selectors
         GPSTIME GetGPSTime();
         MJD     GetMJD();
         YDOYHMS GetYDOYHMS();
         YMDHMS  GetYMDHMS();

         // manipulators
         const CaDateTime &operator=(const CaDateTime &DT2);
		 CaDateTime* operator&(CaDateTime &input);

         CaDateTime operator + ( const double days );
         double   operator - ( const CaDateTime &DT2 );

         bool    operator == ( const CaDateTime &DT2 );
         bool    operator != ( const CaDateTime &DT2 );
         bool    operator >  ( const CaDateTime &DT2 );
         bool    operator >= ( const CaDateTime &DT2 );
         bool    operator <  ( const CaDateTime &DT2 );
         bool    operator <= ( const CaDateTime &DT2 );
		 CString CaDateTime::ToString(void);
      private:
         long        mjd;
         double      fractionOfDay;
   };

} // namespace 

#endif
